<template>
  <div class="message-detail-page" >
    <div class="title">{{ infoData.title }}</div>
    <div class="time">{{ infoData.created_at }}</div>
    <div class="detail">{{ infoData.content }}</div>
  </div>
</template>

<script>
  import { messageDetail } from '@/api/message/index.js'

  export default {
    components: {},
    data() {
      return {
        token: '',
        detailId: 0,
        listLoading: false,
        infoData: {
          id: 1,
          title: '标题',
          create_at: '',
          detail: ''
        }
      };
    },
    onShow() {
      this.token = wx.getStorageSync('access_token');
    },
    onLoad(options) {
      if (options.id) {
        console.log(90909)
        this.detailId = options.id;
        this.initDetail();
      }
    },
    onUnload() {
      this.detailId = '';
      this.infoData = {};
    },
    methods: {
      goLogin() {
        wx.navigateTo({
          url: '/pages/login/main'
        })
      },
      async initDetail() {
        this.token = wx.getStorageSync('token');
        if (!this.token) {
          return false;
        }
        this.listLoading = true;
        const res = await messageDetail({
          id: this.detailId
        })
        if (res.code == 200) {
          this.infoData = res.data
        }
      }
    },
  };
</script>

<style lang="less">
  .message-detail-page {
    padding: 36px 30px;
    margin-bottom: env(12px + safe-area-inset-bottom);
    background: #fff;
    .title {
      font-size: 20px;
      line-height: 28px;
      color: rgba(0, 0, 0, .85);
    }
    .time {
      margin-top: 16px;
      font-size: 16px;
      line-height: 23px;
      color: rgba(0, 0, 0, .45);
    }
    .detail {
      margin-top: 16px;
      font-size: 18px;
      line-height: 28px;
      color: rgba(0, 0, 0, .65);
    }
  }
</style>
